<?php
  session_cache_limiter('private,must-revalide');
   /**
   * 处理上传页面
   */ 
  include_once("./config.php");
  $tpl = new PhplibTpl($conf["admin_tpl_path"]);
  if ($_POST['btn_sub'])
  {
    $cate_id = 0; //分类
	//date_default_timezone_set('Asia/Shanghai');
	$time=date('Y-m-d H:i:s');
	$img = $_FILES['img']['name'];	
	$imgname = explode('.',$img);	
	$count = count($imgname)-1;
	$imgn = time().'.'.$imgname[$count];
	if($_FILES['img']['name']!='')
	{
		$img_file =$conf['fck_upload'] . "adv";
		$file_full = $img_file."/".$imgn;
		$upload_file = $_FILES['img']['tmp_name'];          
		move_uploaded_file($upload_file, $file_full);       
	}
    
    $query = "UPDATE $TBL_CONTACT SET img='$imgn' where id=1";		
    $res = mysql_query($query) or die(mysql_error());	
	MyNotice("圖片編輯成功", 1, "news.php");
    exit(0);
  }  
  $tpl -> set_file(array("main" => "adv.htm"));
  $tpl -> set_block("main", "NEWS_LIST", "news_list");

  $query = "SELECT * FROM $TBL_CONTACT where id=1";
  $result = mysql_query( $query ) or die(mysql_error());
  while($rows = mysql_fetch_array( $result))
  { 
	  $file = '../../upload/adv/'.$rows['img'];
	  if($rows['img']!='')
	  {
		$img = "<img src='$file' width='710' height='190'/>";
	  }
	  $tpl -> set_var(array(
							"img" =>$img,
							));
	  $tpl -> parse("news_list", "NEWS_LIST", true);
  } 
  $tpl->set_var($conf);
  $tpl -> parse("Output", "main");
  $tpl -> p("Output");
  exit(0);
?>